from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from time import sleep


import sys

sys.path.append(r'..')
from web_base.base_page import BasePage
from page_object.login_page import LoginPage

class AssetPage(BasePage):
    url = r'/bsams/front/asset/asset_list.do'

    #借用定位
    add_ben_loc = (By.XPATH, '//*[@id="leftmenu_asset_manage"]/div[1]/a/img')
    add_btn_loc = (By.CLASS_NAME, 'padding5')
    add_departId_loc = (By.ID, 'departId')
    add_remark_loc = (By.ID, 'remark')
    add_ok_loc = (By.CLASS_NAME, 'button_fujian.margin')
    def asset_borrow(self,departId,test):
        self.open()
        self.ele_click(self.add_ben_loc)
        sleep(2)
        self.ele_click(self.add_btn_loc)
        sleep(2)
        self.ele_select(self.add_departId_loc,departId)
        sleep(2)
        self.input_ele(self.add_remark_loc, test)
        sleep(1)
        self.ele_click(self.add_ok_loc)

if __name__ == '__main__':
    departId = '总经理办公室'
    test = '11111'

    chrome_location = r'D:\测试工具\Win_x64_1135105_chrome-win\chrome-win\chrome.exe'
    options = webdriver.ChromeOptions()
    options.binary_location = chrome_location
    driver_location = r'D:\测试工具\pythan\chromedriver.exe'
    service = Service(driver_location)

    driver=webdriver.Chrome(options=options,service=service)

    login_page = LoginPage(driver)
    login_page.login()

    asset_page = AssetPage(driver)
    asset_page.asset_borrow(departId,test)
    driver.quit()